/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.faimg.pomar.modelo.dao;

/**
 *
 * @author diogo
 */
import java.sql.Connection;
import java.sql.DriverManager;

public class ConnectionManager {

        //Configuracao para conexao com o Banco
	//private String url = "jdbc:postgresql://shoryuken:5432/pomar";
    private String url = "jdbc:postgresql://10.0.0.2:5432/pomar";
        //private String url = "jdbc:postgresql://127.0.0.1:5432/pomar";
        //private String url = "jdbc:postgresql://10.0.0.30:5432/pomar"; //maquina do julio
	private String username = "postgres";
	private String password = "1234";
	private String driver = "org.postgresql.Driver";	
	
        // Início Singleton
	private ConnectionManager(){}

	private static ConnectionManager instance = null;

	public static ConnectionManager getInstance(){
		if(instance==null){
			instance = new ConnectionManager();
		}
		return(instance);
	}
	//Termino Singleton
	
     
       	//Metodos de servico
	public Connection getConnection(){
		Connection conn = null;
		try{
			Class.forName(driver);
			conn = DriverManager.getConnection(url,username ,password);
		}
		catch(Exception e){
			System.out.println("Não foi possivel conectar ao bd!");
		}
        return(conn);
	}
}
